package com.example.shiwuyouproject.ui.fragment.my.activity
import com.example.shiwuyouproject.base.BaseVmActivity
import com.example.shiwuyouproject.databinding.ActivitySuccessfulcaseBinding
import com.example.shiwuyouproject.ui.fragment.my.activity.viewmodel.SuccessfulCaseViewModel
import com.example.shiwuyouproject.ui.my.bean.PersonalInformationBean
import com.yechaoa.yutilskt.ToastUtil
import com.yechaoa.yutilskt.YUtils

/**
 * 成功案例
 */
class SuccessfulCaseActivity:BaseVmActivity<ActivitySuccessfulcaseBinding, SuccessfulCaseViewModel>() {
    override fun viewModelClass(): Class<SuccessfulCaseViewModel> = SuccessfulCaseViewModel::class.java

    override fun getViewBinding(): ActivitySuccessfulcaseBinding {
      return  ActivitySuccessfulcaseBinding.inflate(layoutInflater)
    }
    var stCaseTitle=""
    var stCaseDesc=""
    override fun setListener() {
        mBinding.tvBack.setOnClickListener { finish() }
        mBinding.btSava.setOnClickListener {
            YUtils.showLoading(this, "保存中...")
            stCaseTitle=mBinding.etCaseTitle.text.toString()
            stCaseDesc=mBinding.etCaseDesc.text.toString()
            mViewModel.preservationCard(stCaseTitle,stCaseDesc)
        }
    }
    override fun initData() {
        mViewModel.getRealNameAuthenticationData()
    }

    override fun observe() {
        mViewModel.getPostStatus.observe(this,androidx.lifecycle.Observer<Boolean>{
            YUtils.hideLoading()
            if(it){
                ToastUtil.show("提交成功！")
                finish()
            }else{
                ToastUtil.show("提交失败！")
            }
        })
        mViewModel.getGenRenStatus.observe(this,androidx.lifecycle.Observer<PersonalInformationBean>{
            stCaseTitle=it.case_title
            stCaseDesc=it.case_desc
            mBinding.etCaseTitle.setText(stCaseTitle)
            mBinding.etCaseDesc.setText(stCaseDesc)
        })

    }
}